<?php
/**
 * Users Model
 * This model allows for the addition of users to the system.
 */

 class Model_Users extends Zend_Db_Table_Abstract {
 	
	protected $_name = 'users';
	
	/*
	 * This Registers the User with the System
	 */
	public function addUser($fname, $lname, $email, $school, $uname, $password ){
		
		$data = array (
		  
		  'fname' => $fname,
		  'lname' => $lname,
		  'email' => $email,
		  'school' => $school,
		  'username' => $uname,  
		  'password' => hash(md5, $password),
		  'created_at'=> new Zend_Db_Expr("now()")
	);
	$this->insert($data);
	
		}
	
	
	/*
	 * Function: getUser
	 * This returns a specific user when given an id
	 */
	public function getUser($id){
		
		$id = (int)$id;
		$row = $this->fetchRow('id = ' . $id);
		if (!$row) {
		throw new Exception("Count not find row $id");
		}
		return $row->toArray();
	}
	
	/*
	 * Function: deleteUser
	 * This deletes a specific user of the system
	 */
	public function deleteUser($id){
		
		$this->delete('id = ' .(int)$id );
	}
	
	/**
	 * Function: GetUserRole
	 * This returns the role of a user within the sytem.
	 */
	public function getUserRole($id){
		
		
	}
	
	/**
	 * Function: GetAllUsers
	 * @return This returns all the users within the system.
	 */
	public function getAllUsers(){
		
		return $this->fetchAll();
		
	}
	
 }
